package com.ruoyi.service.score.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.service.company.entity.CompanyEntity;
import com.ruoyi.service.score.entity.CompanyScoreEntity;
import com.ruoyi.service.score.mapper.CompanyScoreMapper;
import com.ruoyi.service.score.service.CompanyScoreService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 公司评分表 服务实现类
 * </p>
 *
 * @author Zane
 * @since 2025-10-14
 */
@Service
public class CompanyScoreServiceImpl extends ServiceImpl<CompanyScoreMapper, CompanyScoreEntity>
    implements CompanyScoreService {

  @Override
  public void initScore(CompanyEntity company) {
    CompanyScoreEntity companyScoreEntity = new CompanyScoreEntity()
        .setComId(company.getComId())
        .setAvgScore(0)
        .setCreateBy(company.getCreateBy())
        .setCreateTime(company.getCreateTime())
        .setUpdateBy(company.getUpdateBy())
        .setUpdateTime(company.getUpdateTime());
    save(companyScoreEntity);
  }

  @Override
  public CompanyScoreEntity getByIdCompanyId(Long comId) {
    return getOne(queryWrapper().eq(CompanyScoreEntity::getComId, comId));
  }

  private LambdaQueryWrapper<CompanyScoreEntity> queryWrapper() {
    return new LambdaQueryWrapper<>();
  }
}
